package com.mac.sys.urtils;


import java.util.ArrayList;
import java.util.List;

public class MyStringUtils
{
    public static String getNoSameName()
    {
        StringBuilder sb = new StringBuilder(String.valueOf(System.currentTimeMillis()));
        sb.append(MyStringUtils.getRandomNum());
        sb.append(MyStringUtils.getRandomNum());
        sb.append(MyStringUtils.getRandomNum());
        sb.append(MyStringUtils.getRandomNum());
        return sb.toString();
    }

    public static int getRandomNum()
    {
        return (int) (Math.random() * 10);
    }


    public static String getChineseNo(int alboNo)
    {


        String result = "";

        String[] units = {"", "十", "百", "千", "万", "十万", "百万", "千万", "亿", "十亿", "百亿", "千亿", "万亿"};
        char[] numArray = {'零', '一', '二', '三', '四', '五', '六', '七', '八', '九'};
        char[] val = String.valueOf(alboNo).toCharArray();
        int len = val.length;
        StringBuilder sb = new StringBuilder();
        for (int j = 0; j < len; j++)
        {
            String m = val[j] + "";
            int n = Integer.valueOf(m);
            boolean isZero = n == 0;
            String unit = units[(len - 1) - j];
            if (isZero)
            {
                if ('0' == val[j - 1])
                {
                    continue;
                } else
                {
                    sb.append(numArray[n]);
                }
            } else
            {
                sb.append(numArray[n]);
                sb.append(unit);
            }
        }
        result = sb.toString();
        System.out.println(result);
        return result;

    }

    public static void main(String[] args)
    {
        MyStringUtils.getChineseNo(56);
    }
}
